package com_5;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerTCP {//定义一个服务端
    public static void main(String[] args) throws IOException {//
        ServerSocket ss = new ServerSocket(5000);//
        Socket sc = ss.accept();
        BufferedReader br = new BufferedReader(new InputStreamReader(sc.getInputStream()));
        BufferedWriter bw = new BufferedWriter(new FileWriter("UDP\\sss77777.text"));
        //
        String line;//
        while ((line = br.readLine()) != null) {//
            bw.write(line);//
            bw.newLine();//
            bw.flush();//
        }
        BufferedWriter bw1 = new BufferedWriter(new OutputStreamWriter(sc.getOutputStream()));
        //
        bw1.write("已经收到数据了");//
        bw1.newLine();//
        bw1.flush();//
        bw1.close();//
        br.close();//
        bw.close();//
        ss.close();//
    }
}
